from enum import Enum,unique

Month = Enum('Month',('Jan','Feb','Mar','Apr','May','Jun','Aug','Sep','Oct','Nov','Dec'))
for name,member in Month.__members__.items():
    print(name,'=>',member,',',member.value)


@unique    # 确保枚举值唯一
class Gender(Enum):
    Male = 0
    Female = 1
class Student(object):
    def __init__(self,name,gender):
        if not isinstance(gender,Gender):   # 检查 gender是否为Gender枚举类型
            raise ValueError('gender 必须是 Gender 枚举类型')
        self.name = name
        self.gender = gender
# 测试
bart = Student('Bart',Gender.Male)
if bart.gender == Gender.Male:
    print('测试通过!')
else:
    print('测试失败!')
